%   $Id$
%   
%   File	cbuff.sty
%   Part of	ChessBase utilities file format (CBUFF)
%   Author	Anjo Anjewierden, anjo@swi.psy.uva.nl
%		based on Piet Tutelaer's chess macro's
%   Purpose	LaTeX style file for CBUFF
%   Works with	LaTeX
%   
%   Notice	Copyright (c) 1993  Anjo Anjewierden
%   
%   History	14/07/93  (Created)
%   		31/08/93  (Floating diagrams; PT)
%   		31/08/93  (Last modified)

% Redefine chess.sty to get similar layout as in Informator
\makeatletter
\gdef\@dots{\ldots}
\resetat

\newlength{\arrowwidth}
\newlength{\pluswidth}
\settowidth{\arrowwidth}{$\leftarrow$}
\settowidth{\pluswidth}{+}
\newcommand{\botharrow}{\mbox{\raisebox{1pt}{$\leftarrow$}\hspace*{-\arrowwidth}\raisebox{-2pt}{$\rightarrow$}}}
\newcommand{\plusis}{\mbox{\small\raisebox{3pt}{$+$}\hspace*{-\pluswidth}\raisebox{-2pt}{$=$}}}
\newcommand{\isplus}{\mbox{\small\raisebox{4pt}{$=$}\hspace*{-\pluswidth}\raisebox{-1pt}{$+$}}}
\newcommand{\bottomright}{\mbox{}}
\newcommand{\bottomleft}{\mbox{}}
\newcommand{\smallspace}{{\hskip.1em\ }}
\newcommand{\half}{$\frac{1}{2}$}
\newcommand{\draw}{$\frac{1}{2}$:$\frac{1}{2}$}
\newcommand{\quarter}{\raisebox{3pt}{\tiny$\frac{1}{4}$}}
\newcommand{\threequarter}{\raisebox{3pt}{\tiny$\frac{3}{4}$}}
\newcounter{gameno} \setcounter{gameno}{1}
\newcounter{diagramno} \setcounter{diagramno}{1}
\newcommand{\nogame}[0]{\addtocounter{gameno}{1}}

\def\moves{\list{}{
 \itemindent\listparindent\topsep 0pt\partopsep 0pt
 \rightmargin\leftmargin \parsep 0pt plus 1pt}\item[]}
\let\endmoves=\endlist

\setlength{\parindent}{0pt}

%  Game in the style of the Chess Informant
%  (If anyone knows how to cut down on the amount of space
%   between games, while still ensuring that at least the
%   first move is printed in the same column as the game
%   header, I would like to know (anjo@swi.psy.uva.nl).
\newcommand{\informantgame}[5]{\vfill%\par
	\parbox{\columnwidth}{\rm %
	\begin{center}
	\makebox[\columnwidth]{{\bf \makebox[0pt][l]{\thegameno.}}
			 \hfill \makebox[0pt][c]{#2}
			 \hfill \bf \makebox[0pt][r]{#1}}\\[3pt]
	{#3 --- #4} \\
	{\sl #5}
	\end{center}\nopagebreak}
	\addtocounter{gameno}{1}}

\newenvironment{informantmainline}[2]{\bf\newcommand{\result}{#1}%
   \newcommand{\commentator}{#2}\begin{chess}}%
   {\end{chess}\informantscore{\result}{\commentator}}
\newenvironment{informantvariation}{[\begingroup\rm\ignorespaces}%
   {\endgroup]\ignorespaces}
\newenvironment{informantcomment}{\begin{nochess}\begingroup\rm\ignorespaces}%
   {\end{nochess}\endgroup\ignorespaces}
\newcommand{\informantscore}[2]{{\bf\hfill#1\hfill#2\par}}

%\newenvironment{moves}{\bf\begin{quote}}{\end{quote}}


% diagram environment provides:
%  - automatic numbering
%  - if a diagram does not fit in the text then it will float
%    to the top or bottom and the place where it should occur contains a
%    reference to the diagram number.
% LaTeX does not provide an easy way to test if the reference fits on the
% current page. If it does not fit the diagram and the reference will float
% to the next column. By adding a \newpage just before the diagram in
% question the user can prevent such unwanted references.
\newcounter{diagramnr}
\newcommand{\Diagram}{$$ \setlength{\unitlength}{1pt}
      \begin{picture}(160,160)
         \put(-5,140){\makebox(0,0)[r]{\em\thediagramnr}}
         \put(0,0){\makebox(160,160){\showboard}}
      \end{picture}
   $$}
\newenvironment{diagram}{\begin{nochess}}{\addtocounter{diagramnr}{1}
   % does the diagram fit?
   \par\begin{figure}[htb]\Diagram\end{figure}
   \ifx\@deferlist\@empty\else
      \centerline{\em (Diagram~\thediagramnr)}
   \fi
   \end{nochess}}
\newcommand{\finito}[2]{{\bf\hfill#1\hfill[#2]\par}}
\resetat

\setlength{\parindent}{0pt}
\setcounter{diagramnr}{0}
